package com.lancoo.znbkxx.teacher.adapter

import android.annotation.SuppressLint
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.ClassicWrongQue
import com.lancoo.znbkxx.teacher.utils.HtmlUtils
import kotlinx.android.synthetic.main.item_example_wrongproblem.view.*
import java.math.BigDecimal

/**
 * @author : Admin
 * @date   : 2020/10/28
 * @desc   :
 */
class ExampleWrongQuesAdapter(private val typeName: String, data: MutableList<ClassicWrongQue>) :
        BaseQuickAdapter<ClassicWrongQue, BaseViewHolder>(data) {
    init {
        mLayoutResId = R.layout.item_example_wrongproblem
    }

    @SuppressLint("SetTextI18n")
    override fun convert(helper: BaseViewHolder, item: ClassicWrongQue?) {
        with(helper.itemView) {
            tv_from.text = "来源：${item!!.PaperName}"
            tv_percent.text = "失分率：${
                BigDecimal(item.LoseRate * 100).setScale(0, BigDecimal.ROUND_HALF_UP)
            }%"
            tv_content.text = HtmlUtils.setText(item.Brief)
            tv_type_name.text = typeName
            tv_paper_time.text = item.RecordTime.let { it.substring(0, it.lastIndexOf("T")) }
        }
    }
}